﻿<%@ Page Title="" Language="C#" MasterPageFile="Site.Master" AutoEventWireup="true" CodeBehind="Busca.aspx.cs" Inherits="BYGames.Busca" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <asp:Label ID="Label1" runat="server" Text="Buscar produto: "></asp:Label><asp:TextBox
        ID="TextBox1" runat="server"></asp:TextBox>
    <asp:Button ID="Button1" runat="server" Text="Buscar" />

    <br />
    
    <asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
        AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSource1" 
        EmptyDataText="There are no data records to display.">
        <Columns>
            <asp:BoundField DataField="id" HeaderText="id" ReadOnly="True" 
                SortExpression="id" Visible="False" />
            <asp:BoundField DataField="nome" HeaderText="Nome do produto" SortExpression="nome" />
            <asp:BoundField DataField="desc_breve" HeaderText="Descrição breve" 
                SortExpression="desc_breve" />
            <asp:BoundField DataField="desc_comp" HeaderText="Descrição completa" 
                SortExpression="desc_comp" Visible="False" />
            <asp:BoundField DataField="valor" HeaderText="Valor do produto" SortExpression="valor" />
            <asp:BoundField DataField="fotos" HeaderText="Fotos" SortExpression="fotos" 
                Visible="False" />
            <asp:BoundField DataField="qtd" HeaderText="Quantidade" SortExpression="qtd" />
            <asp:CheckBoxField DataField="status" HeaderText="Status" 
                SortExpression="status" Visible="False" />
            <asp:HyperLinkField DataNavigateUrlFields="id" 
                DataNavigateUrlFormatString="Carrinho.aspx?idProd={0}" HeaderText="Comprar" 
                Text="Comprar" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:bygamesConnectionString %>" 
        DeleteCommand="DELETE FROM [produto] WHERE [id] = @id" 
        InsertCommand="INSERT INTO [produto] ([nome], [desc_breve], [desc_comp], [valor], [fotos], [qtd], [status]) VALUES (@nome, @desc_breve, @desc_comp, @valor, @fotos, @qtd, @status)" 
        SelectCommand="SELECT [id], [nome], [desc_breve], [desc_comp], [valor], [fotos], [qtd], [status] FROM [produto] WHERE ([desc_breve] = @desc_breve)" 
        
        UpdateCommand="UPDATE [produto] SET [nome] = @nome, [desc_breve] = @desc_breve, [desc_comp] = @desc_comp, [valor] = @valor, [fotos] = @fotos, [qtd] = @qtd, [status] = @status WHERE [id] = @id">
        <DeleteParameters>
            <asp:Parameter Name="id" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="nome" Type="String" />
            <asp:Parameter Name="desc_breve" Type="String" />
            <asp:Parameter Name="desc_comp" Type="String" />
            <asp:Parameter Name="valor" Type="Decimal" />
            <asp:Parameter Name="fotos" Type="String" />
            <asp:Parameter Name="qtd" Type="Int32" />
            <asp:Parameter Name="status" Type="Boolean" />
        </InsertParameters>
        <SelectParameters>
            <asp:QueryStringParameter Name="desc_breve" QueryStringField="categoria" 
                Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="nome" Type="String" />
            <asp:Parameter Name="desc_breve" Type="String" />
            <asp:Parameter Name="desc_comp" Type="String" />
            <asp:Parameter Name="valor" Type="Decimal" />
            <asp:Parameter Name="fotos" Type="String" />
            <asp:Parameter Name="qtd" Type="Int32" />
            <asp:Parameter Name="status" Type="Boolean" />
            <asp:Parameter Name="id" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    
    <br />
    </asp:Content>
